package com.team7.stat.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.team7.stat.dao.MemberDao;
import com.team7.stat.entity.Member;
import com.team7.stat.service.MemberService;
import com.team7.stat.utils.CommonResult;
import com.team7.stat.vo.MemberSta;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @ClassName: MemberServiceImpl
 * @Description: 会员表 服务实现类
 * @Author: 赵孟阳
 * @Date: 2021/10/19 21:20
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberDao, Member> implements MemberService {
    @Resource
    private MemberDao memberDao;

    @Override
    public CommonResult queryMemberTypeBang(Member member) {
        List<MemberSta> maps = memberDao.queryMemberTypeBang(member);
        List<Map> collect = maps.stream().map(item -> {
            Map<String, Object> map = new HashMap<>();
            map.put("name", item.getName() ? "会员" : "讲师");
            map.put("value", item.getValue());
            return map;
        }).collect(Collectors.toList());
        return new CommonResult(2000,"查询成功",collect);
    }
}
